package xps.and.uudaijia.userclient.view.activity;

import android.view.View;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;

import com.jude.utils.JUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import rx.Subscriber;
import xps.and.uudaijia.userclient.R;
import xps.and.uudaijia.userclient.data.baen.WEBBean;
import xps.and.uudaijia.userclient.data.net.UserNetWorks;
import xps.and.uudaijia.userclient.view.base.BaseActivity;

/**
 * Created by Administrator on 2017/6/29.
 */

public class MeActivity extends BaseActivity {
    @BindView(R.id.actionbar_iv_back)
    ImageView actionbarIvBack;
    @BindView(R.id.actionbar_tv_title)
    TextView actionbarTvTitle;
    @BindView(R.id.mail_open_html)
    WebView mailOpenHtml;

    @Override
    protected int getLayout() {
        return R.layout.activity_charge;
    }

    @Override
    protected void setData() {
    }

    @Override
    protected void init() {
        ButterKnife.bind(this);
        actionbarTvTitle.setText("关于我们");
        mailOpenHtml.getSettings().setJavaScriptEnabled(true);
        income();
    }


    @OnClick({R.id.actionbar_iv_back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.actionbar_iv_back:
                finish();
                break;
        }
    }

    void income() {
        UserNetWorks.getWEBView("uAboutus", new Subscriber<WEBBean>() {

            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onNext(WEBBean webBean) {
                if (webBean.getReturn_code().equals("SUCCESS")) {
                    mailOpenHtml.loadDataWithBaseURL("about:blank", webBean.getReturn_body(), "text/html", "utf-8", null);
                } else if (webBean.getReturn_code().equals("FAIL")) {
                    JUtils.Toast(webBean.getReturn_msg());
                }

            }
        });
    }
}
